using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;

namespace Entity;

/// <summary>
/// 配置 EF 创建方式，及数据库配置
/// </summary>
public class ApiDbContextFactory : IDesignTimeDbContextFactory<ApiDbContext>
{
    public ApiDbContext CreateDbContext(string[] args)
    {
        var builder = new DbContextOptionsBuilder<ApiDbContext>();

        // 数据库连接方式和版本号
        builder.UseMySql("server=localhost;userid=root;password=123456;port=3306;database=aiydb",
            MySqlServerVersion.LatestSupportedServerVersion);

        return new ApiDbContext(builder.Options);
    }
}